package com.pachong.frameworkdemo.module4;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.pachong.android.baseuicomponent.CompState;
import com.pachong.android.baseuicomponent.fragment.BaseFragment;
import com.pachong.android.frameworkbase.customviews.ImageViewPager;
import com.pachong.frameworkdemo.R;
import com.viewpagerindicator.CirclePageIndicator;

import java.util.ArrayList;
import java.util.List;


/**
 *
 * ImageViewPager 的使用目模版
 *
 */
public class TemplateImageVPFragment extends BaseFragment {


    @Override
    public View createDataView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        View view = layoutInflater.inflate(R.layout.template_fragment_image_viewpager, null);

        ImageViewPager ivp = (ImageViewPager) view.findViewById(R.id.ivp);
        int[] resIds = new int[]{R.drawable.ic_launcher, R.drawable.ic_launcher, R.drawable.ic_launcher, R.drawable.ic_launcher};

        String url1 = "http://img1.gtimg.com/news/pics/hv1/108/200/1978/128670558.jpg";
        String url2 = "http://img1.gtimg.com/news/pics/hv1/108/200/1978/128670558.jpg";
        List<String> urlList = new ArrayList<>();
        urlList.add(url1);
        urlList.add(url2);
        ivp.setupUrls(urlList);

        List<Integer> resList = new ArrayList<>();
        resList.add(R.drawable.ic_launcher);
        resList.add(R.drawable.ic_launcher);

        ivp.setupDrawableIds(resIds);
        setState(CompState.DATA);

        CirclePageIndicator indicator = (CirclePageIndicator) view.findViewById(R.id.indicator);
        indicator.setViewPager(ivp);

        return view;
    }
}
